import { http } from "@/api/http/request";
import type {
  ProductListParams,
  ProductListResponse,ProductDetailResponse,
  ProductDetailSkusResponse,
  CategoryItem,
  ProductItem,
  CreateProductParams,
  CreateSpecTypesParams,
  SpecItem,
  SpecListResponse,
} from "@/api/types/product";
import { API_URLS } from "../constants/api-url";

/**
 * 获取商品分类列表
 */

export const getCategoryList = () => {
  return http.get<CategoryItem[]>(API_URLS.PRODUCT_CATEGORY_LIST);
};
/**
 * 获取商品列表
 * @param params 搜索项
 */
export const getProductList = (params: ProductListParams) => {
  return http.get<ProductListResponse>(API_URLS.PRODUCT_LIST, { params });
};

/**
 * 获取商品详情
 * @param id 商品id
 * @returns 商品详情
 */
export const getProductDetail = (id: string,params?: any) => {
  return http.get<ProductDetailResponse>(API_URLS.PRODUCT_DETAIL + `/${id}`, { params });
}
/**
 * 获取商品sku列表
 * @param id 商品id
 * @returns 商品详情
 */
export const getProductDetailSkus = (id: string,params?: any) => {
  return http.get<ProductDetailSkusResponse>(API_URLS.PRODUCT_DETAIL_SKUS + `/${id}`, { params });
}
/**
 * 创建商品
 * @param params 创建商品参数
 */
export const createProduct = (params: CreateProductParams) => {
  return http.post<ProductItem>(API_URLS.PRODUCT_CREATE, params);
};

/**
 *  更新商品
 */
export const updateProduct = (id: string, params: CreateProductParams) => {
  return http.put<ProductItem>(API_URLS.PRODUCT_UPDATE + `/${id}`, params);
};

/**
 * 获取规格列表
 */

export const getSpecTypesList = (id: string,params?: any) => {
  return http.get<SpecListResponse>(API_URLS.SPEC_TYPES_LIST +`/${id}`, { params });
};
/**
 * 创建规格
 * @param params - 创建规格的参数
 */

export const createSpecTypes = (params: CreateSpecTypesParams) => {
  return http.post<SpecItem>(API_URLS.SPEC_TYPES_CREATE, params);
};

/**
 * 更新规格
 * @param id - 规格的唯一标识符
 * @param params - 更新规格的参数
 */

export const updateSpecTypes = (id: string, params: CreateSpecTypesParams) => {
  return http.put<SpecItem>(API_URLS.SPEC_TYPES_UPDATE +`/${id}`, params);
};

/**
 * 删除特定类型的函数
 * @param id - 要删除的类型的唯一标识符
 * @returns 该函数目前没有返回值
 */
export const deleteSpecType = (id: string) => {};

/**
 * 批量删除规格类型的函数
 * @param ids - 规格类型ID数组，用于指定需要删除的规格类型
 * @returns - 无返回值
 */
export const batchDeleteSpecTypes = (ids: string[]) => {};
